package code;
import java.util.Vector;


public class Bank 
{
	private String fName;
	private Vector<Account> fAccount;
	private static int fNextAccountNum = 0;
	
	/**
	 * Creates a bank. 
	 * @param name of the bank
	 */
	public Bank(String name)
	{
		fName = name;
		fAccount = new Vector<Account>();
	}
	
	/**
	 * Creates only a checking account at the bank
	 * @param first_name first name
	 * @param last_name last name
	 * @param street live
	 * @param zipcode digits
	 * @param town live
	 * @param country live
	 * @return account number
	 */
	public int openSimpleCheckingAccount(String first_name, String last_name, String street, String zipcode, String town, 
			String country)
	{
		CheckingAccount checking_account = new CheckingAccount();
		Account new_account = new Account(first_name, last_name, street, zipcode, town, country, fNextAccountNum,checking_account, null, null, null);
		fAccount.add(new_account);
		
		return fNextAccountNum++;
	}
	
	/**
	 * Creates checking, savings account and debit and credit card. 
	 * @param first_name first name
	 * @param last_name last name
	 * @param street live
	 * @param zipcode digits
	 * @param town live
	 * @param country live
	 * @return account number
	 */
	public int openFullPackage(String first_name, String last_name, String street, String zipcode, String town, 
			String country)
	{
		CheckingAccount newAccount = new CheckingAccount();
		SavingsAccount newSavingsAccount = new SavingsAccount();
		DebitCard newDebetCard = new DebitCard(0, newAccount);

		Account new_account = new Account(first_name, last_name, street, zipcode, town, country, 
				fNextAccountNum,newAccount, newSavingsAccount, newDebetCard, null);
		
		new_account.applyForCreditCard();
		fAccount.add(new_account);
		
		return fNextAccountNum++;
	}
	
	/**
	 * Gets name of the bank
	 * @return name of the bank
	 */
	public String getName(){
		return fName;
	}
	
	/**
	 * Gets the account specified
	 * @param account account num
	 * @return the accoun
	 */
	public Account getAccount(int account){
		if(account > fAccount.size() || 0 > account){
			throw new IllegalArgumentException("invalid account");
		}
		return fAccount.get(account);
		
	}
}
